﻿using BaseUtils.Helper;
using System.Collections.Generic;

namespace Core.UserScript
{

    /// <summary>
    /// 基础脚本类，被动态生存的 RuntimeScript 类所继承
    /// 
    /// 项目中不存在这个类，用户使用脚本节点时会动态生存
    /// 
    /// 
    /// </summary>
    public class NodeBaseScript
    {

        public static string SCRIPT_CLASS_NAME = "NodeScript";
        public static string SCRIPT_CLASS_NAME2 = "RuntimeScript";
        public static string SCRIPT_METHODS_NAME_ASPECT = "Aspect";

        public int GetNode(string NodeId)
        {
            dynamic s = NodeId;
            return 1;
        }

        public static T ToObject<T>(string Json)
        {
            return ConvertHelper.ToObject<T>(Json);
        }

        public static List<T> ToObjects<T>(string Json)
        {
            List<T> Res = ConvertHelper.ToObject<List<T>>(Json);
            return Res;
        }

        public static dynamic GetValue(string Json, string Path)
        {
            return ConvertHelper.GetValueFromDynamicPath(Json, Path);
        }

        public static dynamic GetValue(object Json, string Path)
        {
            return ConvertHelper.GetValueFromDynamicPath(Json.ToJson(), Path);
        }

        public static string ToJson(object Data)
        {
            return Data.ToJson();
        }
    }
}
